//index.js
//获取应用实例
const app = getApp()
const Util = require('../../utils/util.js');
Page({
  data: {
    autoplay: true,
    interval: 5000,
    duration: 1000,
    videUrl:''
  },
  imgHeight: function (e) {
    var winWid = wx.getSystemInfoSync().windowWidth; //获取当前屏幕的宽度
    var imgh = e.detail.height;//图片高度
    var imgw = e.detail.width;//图片宽度
    var swiperH = Math.ceil(winWid * imgh / imgw-5) + "px";
    this.setData({
      height: swiperH//设置高度
    })
  },
  bannerHeight: function (e) {
    var winWid = wx.getSystemInfoSync().windowWidth; //获取当前屏幕的宽度
    var imgh = e.detail.height;//图片高度
    var imgw = e.detail.width;//图片宽度
    var swiperH = Math.ceil(winWid * imgh / imgw - 5) + "px";
    this.setData({
      bannerHeight: swiperH//设置高度
    })
  },
  cateList:function(e){
    var cate_id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: 'list?cate_id='+cate_id
    })
  },
  process:function(){
    wx.navigateTo({
      url: 'about?id=1'
    })
  },
  cooperation: function () {
    wx.navigateTo({
      url: 'contact?id=2'
    })
  },
  product:function(){
    wx.navigateTo({
      url: 'list'
    })
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  moreList:function(){
    wx.navigateTo({
      url: 'list?is_recomment=1'
    })
  },
  goodsDetail: function (e) {
    var id = e.currentTarget.dataset.id;
    if(id){
      wx.navigateTo({
        url: 'detail?id='+id
      })
    }
  },
  onLoad: function () {
    this.getAdList();
    this.getCateList();
    this.getRecommentList();
 
  },
  getRecommentList:function(){
    var that = this;
    Util.getRecommentList({}, function (re) {
      console.info(re);
      that.setData({
        goods_list: re.data
      })
    })
  },
  getCateList:function(){
    var that = this;
    Util.getCateList({}, function (re) {
      console.info(re);
      that.setData({
        cate_list: re.data
      })
    })
  },
  getAdList:function(){
    var that = this;
    Util.getIndex({},function(re){
      console.info(re);
      that.setData({
        imgUrls:re.data,
        adList:re.ad
      })
    })
  },
  onShareAppMessage: function (res) {
    return {
      title: '港澳保险,海外资产配置,家族资产管理',
      path: '/pages/index/index'
    }
  },
})
